package services

import (
	"gin-study/app/dao"
	"gin-study/app/http/requests"
	"gin-study/app/models"
)

var UserOrder *userOrder

func init() {
	UserOrder = new(userOrder)
}

type userOrder struct{}

func (this *userOrder) GetUserOrders(userId uint, page *requests.Page) *models.Paginator {
	tx := dao.Order.Scopes(dao.Order.ScopeUserId(userId))
	tx = tx.Order("id DESC")
	return dao.Paginate(tx, &[]models.Order{}, page.Page, page.Limit)
}
